package adv6;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author oldliu
 * @since 1.0
 */
public class ClsTest {
    public static void main(String[] args) throws ClassNotFoundException {
        Class<ClsTest> c0 = ClsTest.class;
        Class<Integer> c1 = int.class;
        Class<String> c2 = String.class;
        String str="方德市";
        Class<? extends String> c3 = str.getClass();
        System.out.println(c2==c3);
        Class c4=Class.forName("java.lang.String");
        System.out.println(c3==c4);
        System.out.println("父类："+c2.getSuperclass().getName());
        Class<?>[] cr = c2.getInterfaces();
        System.out.println(Arrays.toString(cr));
        //所有的属性
        Field[] fields = c2.getDeclaredFields();
        Method[] methods = c2.getDeclaredMethods();
        System.out.println("构造方法");
        Constructor<?>[] constructors = c2.getDeclaredConstructors();
        for (Constructor constructor :constructors){
            System.out.println(constructor);
        }

    }
}
